package song.demo;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import song.demo.bean.UserBean;
import song.demo.service.UserService;

import javax.annotation.Resource;
import java.util.List;

@RunWith(SpringRunner.class)
@SpringBootTest
public class Tests {
    @Resource
    UserService userService;
    @Test
    public void contextLoads(){
        UserBean userBean = userService.login("5", "5");
        if (userBean != null) {
            System.out.println("该用户名为:");
            System.out.println(userBean.getName());
        }
        List<UserBean> userList = userService.getAllUser();

        /*//插入
        userBean = new UserBean();
        userBean.setId(7);
        userBean.setName("七夕");
        userBean.setPassword("777");
        userBean.setRole("admin");
        int nFlag = userService.insertUser(userBean);*/

//        int nFlag = userService.deleteUser("2");     //删除   谢小华

//        UserBean userById = userService.getUserById("3");
//        System.out.println(userById.getName()+userById.getRole());

        UserBean userBean1 = new UserBean();
        userBean1.setName("我是新的超级管理员");
        userBean1.setPassword("666");
        userBean1.setRole("user");
        userBean1.setId(11);

        int nflag = userService.updateUser(userBean1);
    }

}
